
<%@ page import="org.apache.ibatis.session.SqlSession" %>

<%@ page import="java.util.Date" %>
<%@ page import="java.text.SimpleDateFormat" %>
<%@ page import="myschool.dao.StudentDao" %>
<%@ page import="myschool.entity.Student" %>
<%@ page import="myschool.util.MybatisUtil" %>
<%@ page import="myschool.biz.StudentService" %><%--
  Created by IntelliJ IDEA.
  User: 12262
  Date: 2023/4/6
  Time: 13:48
  To change this template use File | Settings | File Templates.
--%>
<%@ page contentType="text/html;charset=UTF-8" language="java" %>
<html>
<head>
    <title>Title</title>
</head>
<body>
<%
    request.setCharacterEncoding("UTF-8");
    SimpleDateFormat simpleDateFormat=new SimpleDateFormat("yyyy-MM-dd");
    String sname = request.getParameter("sname");
    String sex = request.getParameter("sex");
    String telephone = request.getParameter("telephone");
    String qq = request.getParameter("qq");
    String wechat = request.getParameter("wechat");
    int gradeid = Integer.parseInt(request.getParameter("gradeid"));
    Date enterdate =simpleDateFormat.parse(request.getParameter("enterdate"));
    String fromcity = request.getParameter("fromcity");
    Date birthday=simpleDateFormat.parse(request.getParameter("birthday"));
    String address = request.getParameter("address");
    String pass = request.getParameter("pass");
    String idcardpic = request.getParameter("idcardpic");
    //SqlSession session1 = MybatisUtil.get();
    //StudentDao mapper = session1.getMapper(StudentDao.class);
    Student student=new Student(sname,sex,telephone,qq,wechat,gradeid,enterdate,fromcity,birthday,address,pass);
    student.setIdcardpic(idcardpic);
    //StudentService studentService=new StudentService();
    int add = StudentService.ME.add(student);
    if ( add>0 ){
        out.println("输入成功");
    }else {
      // out.println("输入失败");
        %>
<div>
    <h4>保存失败<button type="button"  onclick="window.history.back();"  id="goback">返回</button> </h4>
</div>
<%
    }
   // session1.commit();
   // MybatisUtil.close(session1);
%>
</body>
</html>
